package com.example.music.activity

import com.example.lib_common_ui.base.BaseActivity
import com.example.music.R
import com.example.music.adapter.MainAdapter
import com.example.music.databinding.ActivityMainBinding
import com.example.music.fragment.CircleFragment
import com.example.music.fragment.HomeFragment
import com.example.music.fragment.LiveFragment
import com.example.music.fragment.MyFragment
import com.google.android.material.tabs.TabLayoutMediator

class MainActivity : BaseActivity<ActivityMainBinding>() {
    override fun initUI() {
        super.initUI()
        initViewPagerAndTabLayout()

    }

    private fun initViewPagerAndTabLayout() {
        mBinding.Page.isUserInputEnabled = false
        mBinding.Page.adapter = MainAdapter(
            this, listOf(
                HomeFragment(),
                LiveFragment(),
                CircleFragment(),
                MyFragment(),
            )
        )
        TabLayoutMediator(mBinding.tableLayout, mBinding.Page) { tab, position ->
            when (position) {
                0 -> {
                    tab.setIcon(R.drawable.tab_home)
                    tab.setText("主页")
                }

                1 -> {
                    tab.setIcon(R.drawable.tab_live)
                    tab.setText("现场")
                }

                2 -> {
                    tab.setIcon(R.drawable.tab_circle)
                    tab.setText("圈子")
                }

                3 -> {
                    tab.setIcon(R.drawable.tab_me)
                    tab.setText("我的")
                }
            }
        }.attach()

    }

}